<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.css" rel="stylesheet" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav" style="border: red solid 1px;">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">添加好友</h1>
		</header>
		
		<div class="mui-content">
			<div style="height: 50px;">
				<input type="text" id="id" placeholder="xxx" style="float: left;"/>
				<button id="search_submit" style="float: left;">搜索</button>
			</div>
			
		</div>
		
		<script src="js/mui.js"></script>
		<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			mui.init()
			mui.plusReady(function () {
			    var search_submit = document.getElementById("search_submit");
				search_submit.addEventListener("tap", function() {
					var id_txt = document.getElementById("id");
					mui.ajax(app.serverAddress + "/u/s", {
						data: {
							id: id_txt.value
						},
						dataType: 'jsonp',
						jsonp: "callback",
						type: 'post',
						timeout: 10000,
						headers:{'Content-Type':'application/json'},
						success: function(data) {
							var o = JSON.parse(data);							
							if (o.status == 200)
								mui.openWindow({
									url: "user_detail.html",
									extras: {
										u: o.object,
										from: "search_friend.html"
									}
								});
							else
								alert("User is not registered!");
						},
						error: function(xhr, type, errorThrown) {
							alert(xhr.responseText);
						}
					})
				});
			});
		</script>
	</body>

</html>
